package easy;

public class Solution_1869 {

    public boolean checkZeroOnes(String s) {
        char pre = s.charAt(0);
        int max_count_0 = 0, max_count_1 = 0, count_0 = '1' - pre, count_1 = pre - '0';
        for (int i = 1; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c != pre) {
                if (pre == '0') {
                    max_count_0 = Math.max(count_0, max_count_0);
                    count_0 = 0;
                    count_1 = 1;
                } else {
                    max_count_1 = Math.max(count_1, max_count_1);
                    count_0 = 1;
                    count_1 = 0;
                }
            } else {
                if (pre == '0') {
                    count_0++;
                } else {
                    count_1++;
                }
            }
            pre = c;
        }
        return Math.max(count_1, max_count_1) > Math.max(count_0, max_count_0);
    }

    public static void main(String[] args) {
        Solution_1869 model = new Solution_1869();
        System.out.println(model.checkZeroOnes("1"));
        System.out.println(model.checkZeroOnes("1101"));
        System.out.println(model.checkZeroOnes("111000"));
        System.out.println(model.checkZeroOnes("110100010"));
    }
}
